//
//  APPLEMainTableViewController.swift
//  123
//
//  Created by pangjiaxing on 15/12/28.
//  Copyright © 2015年 pangjiaxing. All rights reserved.
//

import UIKit

class APPLEMainTableViewController: UITableViewController {
    
    var userIslanding:Bool = APPLEUserAccountViewModel.sharedViewModel.userLogin
    
    override func loadView() {
        userIslanding == true ? super.loadView() : loadMainView()
    }
    
    private func loadMainView(){
        view=visitorView
//        view.backgroundColor=UIColor.redColor()
        navigationItem.rightBarButtonItem = UIBarButtonItem( title: "登录", targat: self, action: "didClickRightLoadButton")
        navigationItem.leftBarButtonItem = UIBarButtonItem( title: "注册", targat: self, action: "didClickLeftLoadButton")
        
        visitorView.loginButton.addTarget(self, action: "didClickRightLoadButton", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView.registerButton.addTarget(self, action: "didClickLeftLoadButton", forControlEvents: UIControlEvents.TouchUpInside)
    }
    override func viewDidLoad() {
        
       super.viewDidLoad()
        
    }
    
    func didClickRightLoadButton(){
        
        print("哎呦你点击了我，我在APPLEMainTableViewController中，来打我啊~~么么哒,我是传说中的访客视图，正在登录中")
       let VC = APPLENavigationViewController(rootViewController: APPLEAuthViewController())
        
        presentViewController(VC, animated: true, completion: nil)
        
    }
    
    func didClickLeftLoadButton(){
        print("哎呦你点击了我，我在APPLEMainTableViewController中，来打我啊~~么么哒,我是传说中的访客视图，正在注册中")
    }
    lazy var visitorView:APPLEVisitorView={
            let visitor=APPLEVisitorView()
            return visitor
    }()
}
